package com.ccq.controller;

import com.ccq.model.Admin;
import com.ccq.service.LastIndexService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping(value = { "last" })
public class LastIndexController {
    @Autowired
    LastIndexService lastIndexService;

    @GetMapping("login")
    public String flogin(HttpServletRequest request, HttpServletResponse response){
        return "login";
    }

    @GetMapping("index")
    public String findex(HttpServletRequest request, HttpServletResponse response){
        return "last_index";
    }

    @GetMapping("second")
    public String fsecond(HttpServletRequest request, HttpServletResponse response){
        return "last_second";
    }

    @GetMapping("renting")
    public String frenting(HttpServletRequest request, HttpServletResponse response){
        return "last_renting";
    }

    @GetMapping("record")
    public String frecord(HttpServletRequest request, HttpServletResponse response){
        return "last_record";
    }

    @GetMapping("user")
    public String fuser(HttpServletRequest request, HttpServletResponse response){
        return "last_user";
    }

    @GetMapping("person")
    public String fperson(HttpServletRequest request, HttpServletResponse response){
        return "last_person";
    }

    @GetMapping("knowledge")
    public String fknowledge(HttpServletRequest request, HttpServletResponse response){
        return "last_knowledge";
    }

    @GetMapping("floor")
    public String floor(HttpServletRequest request, HttpServletResponse response){
        return "last_floor";
    }

    @GetMapping("allfloor")
    public String fallfloor(HttpServletRequest request, HttpServletResponse response){
        return "last_allfloor";
    }

    @ApiOperation(value="后台登陆", notes="后台登陆")
    @RequestMapping(value = "logins",method = RequestMethod.POST )
    @ResponseBody
    public Admin lastlogin(Admin admin){
        System.out.println(admin.getUsername()+" "+admin.getPassword());
        Admin login=lastIndexService.lastlogin(admin);
        System.out.println(login);
        return login;
    }
}
